diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py
--- a/swh/web/browse/snapshot_context.py
+++ b/swh/web/browse/snapshot_context.py
@@ -480,7 +480,7 @@
             )
 
         visit_url = reverse("browse-origin-directory", query_params=query_params)
-        visit_info["url"] = visit_url
+        visit_info["url"] = directory_url = visit_url
 
         branches_url = reverse("browse-origin-branches", query_params=query_params)
 
@@ -489,6 +489,7 @@
         assert snapshot_id is not None
         branches, releases, aliases = get_snapshot_content(snapshot_id)
         url_args = {"snapshot_id": snapshot_id}
+        directory_url = reverse("browse-snapshot-directory", url_args=url_args)
         branches_url = reverse("browse-snapshot-branches", url_args=url_args)
 
         releases_url = reverse("browse-snapshot-releases", url_args=url_args)
@@ -611,6 +612,7 @@
                 revision_info["message_header"] = ""
 
     snapshot_context = SnapshotContext(
+        directory_url=directory_url,
         branch=branch_name,
         branch_alias=branch_name in aliases,
         branches=branches,
diff --git a/swh/web/common/typing.py b/swh/web/common/typing.py
--- a/swh/web/common/typing.py
+++ b/swh/web/common/typing.py
@@ -131,6 +131,8 @@
     """common URL arguments when browsing snapshot content"""
     visit_info: Optional[OriginVisitInfo]
     """optional origin visit info associated to the snapshot"""
+    directory_url: Optional[str]
+    """optional root directory URL associated to the snapshot"""
 
 
 class SWHObjectInfo(TypedDict):
diff --git a/swh/web/templates/includes/snapshot-context.html b/swh/web/templates/includes/snapshot-context.html
--- a/swh/web/templates/includes/snapshot-context.html
+++ b/swh/web/templates/includes/snapshot-context.html
@@ -37,7 +37,7 @@
 
 <ul class="nav nav-tabs" id="swh-snapshot-context-nav" style="padding-left: 5px;">
   <li class="nav-item">
-    <a class="nav-link" id="swh-browse-code-nav-link" href="{{ snapshot_context.visit_info.url }}">
+    <a class="nav-link" id="swh-browse-code-nav-link" href="{{ snapshot_context.directory_url }}">
       <i class="mdi mdi-code-tags mdi-fw" aria-hidden="true"></i>
       Code
     </a>
@@ -84,4 +84,4 @@
 
 <script>
   swh.browse.initBrowseNavbar();
-</script>
\ No newline at end of file
+</script>
diff --git a/swh/web/tests/browse/test_snapshot_context.py b/swh/web/tests/browse/test_snapshot_context.py
--- a/swh/web/tests/browse/test_snapshot_context.py
+++ b/swh/web/tests/browse/test_snapshot_context.py
@@ -130,6 +130,7 @@
 
         branches_url = reverse("browse-snapshot-branches", url_args=url_args)
         releases_url = reverse("browse-snapshot-releases", url_args=url_args)
+        directory_url = reverse("browse-snapshot-directory", url_args=url_args)
         is_empty = not branches and not releases
         snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot)
         snapshot_sizes = archive_data.snapshot_count_branches(snapshot)
@@ -156,6 +157,7 @@
             snapshot_swhid=snapshot_swhid,
             url_args=url_args,
             visit_info=None,
+            directory_url=directory_url,
         )
 
         if revision_id:
@@ -227,7 +229,7 @@
         snapshot_swhid = gen_swhid(ObjectType.SNAPSHOT, snapshot)
         snapshot_sizes = archive_data.snapshot_count_branches(snapshot)
 
-        visit_info["url"] = reverse(
+        visit_info["url"] = directory_url = reverse(
             "browse-origin-directory", query_params=query_params
         )
         visit_info["formatted_date"] = format_utc_iso_date(visit_info["date"])
@@ -257,6 +259,7 @@
             snapshot_swhid=snapshot_swhid,
             url_args={},
             visit_info=visit_info,
+            directory_url=directory_url,
         )
 
         if revision_id: